<%@ include file="../WEB-INF/jspf/acesso.jspf" %>
<%@ include file="../WEB-INF/jspf/setMeta.jspf" %>
<%@ include file="../WEB-INF/jspf/varGlobal.jspf" %>

<sql:query var='rsetUsuario' dataSource='${con}'>    
    SELECT Usuario.usuario, Usuario.nome, Usuario.equipe FROM Usuario 
    WHERE Usuario.usuario LIKE '%<%out.print( session.getValue("usuarioLogado"));%>%'
</sql:query>

<sql:query var='rsetUsuarios' dataSource='${con}'>    
    SELECT Usuario.usuario, Usuario.nome, Usuario.equipe FROM Usuario 
    WHERE Usuario.equipe LIKE '%<c:out value="${rsetUsuario.rowsByIndex[0][2]}"/>%'
    AND Usuario.statusUsuario LIKE 'Ativo'
</sql:query>

<sql:query var='rsetEquipe' dataSource='${con}'>    
    SELECT Equipe.sigla FROM Equipe 
    ORDER BY `sigla` ASC 
</sql:query>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Delegar Solicita&ccedil;&atilde;o de Atendimento</title>
<link rel="stylesheet" type="text/css" href="./stilos.css" />

</head>

<body>
<form name="form1" method="post" action="../controller/delegarSolicitacao.jsp">
  <fieldset>
  <legend><font color="#0000FF"><strong>Delegar a Solicita&ccedil;&atilde;o '<c:out value="${param.chv1}"/>'.</strong></font></legend>  
  <p>&nbsp;</p>
  <table width="100%" border="1">
    <tr bgcolor="#00CCFF"> 
      <td width="66%" > <div align="center"><strong>Distribuidores</strong></div></td>
    </tr>
    <tr> 
      <td height="20"><div align="center"> 
          <table width="99%" border="2">
           <c:forEach var="row" items="${rsetEquipe.rowsByIndex}">   
                <tr> 
                  <td align="center" bordercolor="#00FFFF" bgcolor="#CCCCCC"><input name="escolha" type="button" value="${row[0]}" onclick="javascript:montaParaEquipe('Distribuidor <c:out value="${row[0]}"/>','<c:out value="${row[0]}"/>')" ></td>
                </tr>
           </c:forEach>
          </table>
        </div></td>
    </tr>
    <tr> 
      <td height="20" bgcolor="#00CCFF">
<div align="center"><strong>Sua Equipe</strong></div></td>
    </tr>
    <tr> 
      <td height="20" bgcolor="#CCCCCC">
<div align="center">
          <table width="99%" border="2">
            <c:forEach var="row" items="${rsetUsuarios.rowsByIndex}">
                <tr> 
                  <td align="center" bordercolor="#00FFFF" bgcolor="#CCCCCC"><input name="escolha" type="button" value="${row[1]}" onclick="javascript:monta('<c:out value="${row[1]}"/>')" ></td>
                </tr>
            </c:forEach>
          </table>
        </div></td>
    </tr>
 </table>
  
  <input type="hidden" name="idSolicitacao" value="" />
  <input type="hidden" name="equipe" value="" />
  <input type="hidden" name="tecnico" value="" />
  <input type="hidden" name="status" value="" />
  <input type="hidden" name="percentual" value="" />
  
 <script language="javascript" type="text/javascript">
      
      function monta(tec){
      
      var nome = tec;      
      document.form1.idSolicitacao.value = <c:out value="${param.chv1}"/>;
      document.form1.equipe.value = "<c:out value="${rsetUsuarios.rowsByIndex[0][2]}"/>";
      document.form1.tecnico.value = nome;
      document.form1.status.value = "Delegada";
      document.form1.percentual.value = "10";
      document.form1.submit();
      
      }
      
      function montaParaEquipe( tec, equipe ){
      
      var nome = tec;      
      document.form1.idSolicitacao.value = <c:out value="${param.chv1}"/>;
      document.form1.equipe.value = equipe;
      document.form1.tecnico.value = nome;
      document.form1.status.value = "Delegada";
      document.form1.percentual.value = "10";
      document.form1.submit();
      
      }
      
  </script>
  
  
  
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  </fieldset>
</form>

</body>
</html>
